import Button from "components/Base/Button";
import Icon from "components/Base/Icon";
import DataTable from "components/Base/DataTable";
import {getBpDeviceType} from "../../../../models/deviceType";

export default (self) => [
  {
    title: 'id',
    name: 'id',
    formItem: {
      type: 'hidden'
    },
  },
  {
    title: '设备ID',
    name: 'numeration',
    tableItem: {
      sorter: true,
    },
    formItem: {
      rules: [
        {
          required: true,
          message: '请输入设备ID'
        }
      ]
    },
  },
  {
    title: 'mac地址',
    name: 'mac',
    tableItem: {},
    formItem: {}
  },
  {
    title: '绑定患者',
    name: 'patientId',
    tableItem: {},
    formItem: {}
  },
  {
    title: '血压型号',
    name: 'deviceType',
    dict: getBpDeviceType(),
    tableItem: {},
    formItem: {
      type: 'select',
      rules: [
        {
          required: true,
          message: '请选择血压型号'
        }
      ]
    }
  },
  {
    title: '状态',
    name: 'state',
    tableItem: {
      filters: [
        {
          value: 'online',
          text: '在线',
        },
        {
          value: 'offline',
          text: '离线',
        },
      ]
    },
    formItem: {
      type: 'hidden'
    }
  },
  {
    title: '操作',
    tableItem: {
      width: 180,
      render: (text, record) => (
        <DataTable.Oper>
          <Button tooltip="修改" onClick={e => self.onUpdate(record)}>
            <Icon type="edit"/>
          </Button>
          <Button tooltip="删除" onClick={e => self.onDelete(record)}>
            <Icon type="trash"/>
          </Button>
        </DataTable.Oper>
      )
    }
  }
]
